#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void system (int n)
{
    if(n)
	{
	    system(n/6);
	    printf("%d",n%6);
	}
}
int main ()
{
	int n = 0;
	scanf("%d",&n);
	system(n); 
	printf("\n");
    return 0;
}